package testUnitaire;

/**
 * Write a description of class Etudiant here.
 * 
 * @author (your name)
 * @version (a version number or a date)
 */
public class Etudiant {
	// instance variables - replace the example below with your own
	private String nomEtudiant;
	private float note1;
	private float note2;
	private Formation formation = null;

	/**
	 * Constructor for objects of class Etudiant
	 */
	public Etudiant() {
		this.nomEtudiant = "toto";
	}

	/**
	 * Constructor for objects of class Etudiant
	 */
	public Etudiant(String nomEtudiant) {
		this.nomEtudiant = nomEtudiant;
	}

	/**
	 * Getter de l'attribut nomEtudiant
	 */
	public String getNomEtudiant() {
		return this.nomEtudiant;
	}

	/**
	 * Setter de l'attribut nomEtudiant
	 */
	public void setNomEtudiant(String nomEtudiant) {
		this.nomEtudiant = nomEtudiant;

	}

	/**
	 * Getter de l'attribut note1
	 */
	public float getNote1() {
		return this.note1;
	}

	/**
	 * Setter de l'attribut note1
	 */
	public void setNote1(float note1) {
		this.note1 = note1;
	}

	/**
	 * Getter de l'attribut note2
	 */
	public float getNote2() {
		return this.note2;
	}

	/**
	 * Setter de l'attribut note2
	 */
	public void setNote2(float note2) {
		this.note2 = note2;
	}

	/**
	 * @return the formation
	 */
	public Formation getFormation() {
		return formation;
	}

	/**
	 * @param formation
	 *            the formation to set
	 */
	public void setFormation(Formation formation) {
		this.formation = formation;
	}

	/**
	 * 
	 * An example of a method - replace this comment with your own
	 * 
	 * @param y
	 *            a sample parameter for a method
	 * @return the sum of x and y
	 */
	public float moyenne() {
		return (this.note1 + this.note2) / 2;
	}

	/**
	 * Methode permettant d'ajouter des notes.
	 */
	public void noter(float note1, float note2) {
		if (note1 < 0) {
			note1 = 0;
		}
		if (note2 < 0) {
			note2 = 0;
		}
		if (this.getFormation() != null
				&& this.getFormation().getListeEtudiant().size() != 0) {
			this.setNote1(note1);
			this.setNote2(note2);
		}
	}
}
